package com.ruoyi.web.controller.wb;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.wb.domain.WbUserEntAuth;
import com.ruoyi.wb.service.IWbUserEntAuthService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 登录用户和认证企业关联Controller
 * 
 * @author ruoyi
 * @date 2024-10-17
 */
@Api(tags="用户和认证企业关联")
@RestController
@RequestMapping("/wbsystemauth")
public class WbUserEntAuthController extends BaseController
{
    @Autowired
    private IWbUserEntAuthService wbUserEntAuthService;

    /**
     * 查询登录用户和认证企业关联列表
     */
    @GetMapping("/list")
    public TableDataInfo list(WbUserEntAuth wbUserEntAuth)
    {
        startPage();
        List<WbUserEntAuth> list = wbUserEntAuthService.selectWbUserEntAuthList(wbUserEntAuth);
        return getDataTable(list);
    }

    /**
     * 导出登录用户和认证企业关联列表
     */
    @Log(title = "导出登录用户和认证企业关联", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WbUserEntAuth wbUserEntAuth)
    {
        List<WbUserEntAuth> list = wbUserEntAuthService.selectWbUserEntAuthList(wbUserEntAuth);
        ExcelUtil<WbUserEntAuth> util = new ExcelUtil<WbUserEntAuth>(WbUserEntAuth.class);
        util.exportExcel(response, list, "登录用户和认证企业关联数据");
    }

    /**
     * 获取登录用户和认证企业关联详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(wbUserEntAuthService.selectWbUserEntAuthById(id));
    }

    /**
     * 新增登录用户和认证企业关联
     */
    @Log(title = "新增登录用户和认证企业关联", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WbUserEntAuth wbUserEntAuth)
    {
        return toAjax(wbUserEntAuthService.insertWbUserEntAuth(wbUserEntAuth));
    }

    /**
     * 修改登录用户和认证企业关联
     */
    @Log(title = "修改登录用户和认证企业关联", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WbUserEntAuth wbUserEntAuth)
    {
        return toAjax(wbUserEntAuthService.updateWbUserEntAuth(wbUserEntAuth));
    }

    /**
     * 删除登录用户和认证企业关联
     */
    @Log(title = "删除登录用户和认证企业关联", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(wbUserEntAuthService.deleteWbUserEntAuthByIds(ids));
    }
}
